﻿using System;
using System.Text;

using BizElements.Core;
using BizElements.Core.ProviderComponents;

namespace BizElements.Core.Firebird
{
    sealed class FirebirdColumnRenderer : IColumnRenderer
    {
        public void RenderColumnName(IDbColumn column, StringBuilder output)
        {
            // Special characters must be enclosed in quotes.
            bool hasSpecChars = TextUtil.HasSpecialChars(column.ColumnName);
            if (hasSpecChars)
                output.Append("\"");

            output.Append(column.ColumnName);
            if (hasSpecChars)
                output.Append("\"");
        }

        public void RenderAlias(IDbColumn column, StringBuilder output)
        {
            // Special characters must be enclosed in quotes.
            bool hasSpecChars = TextUtil.HasSpecialChars(column.Alias);
            if (hasSpecChars)
                output.Append("\"");

            output.Append(column.Alias);
            if (hasSpecChars)
                output.Append("\"");
        }
    }
}